﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;

using YouHP.BLL;
using YouHP.Model;
using YouHP.Utility;

namespace web.admin
{
    public partial class AdminLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Clear();
        }

        /// <summary>
        /// 用户登陆验证
        /// </summary>
        protected void buttonOK_Click(object sender, EventArgs e)
        {
            AdminInfo adminInfo = null;
            if ((textboxUserName.Text.Trim() != null) && (textboxPassword.Text.Trim() != null))
            {
                adminInfo = new AdminInfo();
                adminInfo.Name = textboxUserName.Text.Trim();
                adminInfo.Password = textboxPassword.Text.Trim();
                AdminInfo gottenAdminInfo = new AdminInfo();
                gottenAdminInfo.ID = -1;
                //gottenAdminInfo = AdminBLL.Instance.GetAdminByNameAndPassword(adminInfo);
                //if (gottenAdminInfo.ID != -1)
                if ((adminInfo.Name == "Admin") && (adminInfo.Password == "i@youhp"))
                {
                    Session["AdminInfo"] = gottenAdminInfo;
                    Response.Redirect("index.aspx");
                }
                else
                {
                    Response.Write("<script>alert('用户名或密码错误！');</script>");
                }
            }
            else
            {
                    Response.Write("<script>alert('用户名或密码不能为空！')</script>");
            }
        }
    }
}
